package com.schematic.flixel.spaceinvaders
{
import org.flixel.FlxSprite;
import org.flixel.FlxEmitter;
import org.flixel.FlxG;

public class ClusterBomb extends FlxSprite
{
    public function ClusterBomb(x:Number, y:Number)
    {
        super(x, y);
        createGraphic(2, 15, 0xFFFFFFFF);
        velocity.y = -500;
    }
    
    //--------------------------------------------------------------------------
    //
    //  Overridden Methods - FlxObject
    //
    //--------------------------------------------------------------------------
    
    override public function update():void
    {
        super.update();
        if (y < -height)
            super.kill();
    }
    
    override public function kill():void
    {
        var emitter:FlxEmitter = new FlxEmitter(x + origin.x, y);
        emitter.delay = 1;
        emitter.gravity = 0;
        emitter.setXSpeed(-700, 500);
        emitter.setYSpeed(-700, 200);
        
        var particle:FlxSprite;
        var particlers:int = 10;
        for (var i:int = 0; i < particlers; i++)
        {
            particle = new FlxSprite()
            particle.createGraphic(4, 4, 0xFFFFFFFF);
            emitter.add(particle);
        }
        emitter.start();
        (FlxG.state as PlayState).bullets.add(emitter);
        super.kill();
    }
}
}